package cn.wp.ewallet.wallet.dao.impl;

import cn.wp.common.core.dao.SqlString;
import cn.wp.ewallet.wallet.dao.UserWalletRelDao;
import cn.wp.ewallet.wallet.model.entity.UserWalletRelDo;
import org.springframework.stereotype.Repository;
import cn.wp.common.core.dao.JdbcSupportTemplate;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用户和钱包关系-数据访问层实现
 * Created by zhangyongli on 2020/01/10
 */
@Repository
public class UserWalletRelDaoImpl implements UserWalletRelDao {

    @Autowired
    private JdbcSupportTemplate jdbcSupportTemplate;

    @Override
    public void insertUserWalletRel(UserWalletRelDo userWalletRelDo) {
        jdbcSupportTemplate.insert(userWalletRelDo);
    }

    @Override
    public UserWalletRelDo selectUserWalletRel(String userId) {
        SqlString sqlString = new SqlString();
        sqlString.add("select * from user_wallet_rel ur where ur.user_id = ?");
        return jdbcSupportTemplate.selectObject(sqlString.build(), new Object[]{userId}, UserWalletRelDo.class);
    }
}